#include <iostream>
#include "../../include/lecture2/sales_data.h"

int main()
{
    SalesData book;
    cout << "Enter sales data:" << endl;
    if (cin >> book)
    {
        cout << "Book: " << book.get_bn() << endl;
    }

    SalesData t1, t2;
    cout << "Enter two same bn books:" << endl;
    cin >> t1 >> t2;
    if (compare_bn(t1, t2))
    {
        cout << "The same book!" << endl;
        cout << "Total: " << t1 + t2 << endl;
    }
    else
    {
        cout << "Not the same book!" << endl;
    }

    SalesData total, trans;
    cout << "Enter some same bn books:" << endl;
    if (cin >> total)
    {
        while (cin >> trans)
        {
            if (compare_bn(total, trans))
            {
                total += trans;
            }
            else
            {
                cout << "Not the same book!" << endl;
                break;
            }
            cout << "Total: " << total << endl;
        }
    }
    else
    {
        cout << "No data!" << endl;
        return -1;
    }

    int num = 1;
    cout << "Enter some record:" << endl;
    if (cin >> t1)
    {
        while (cin >> t2)
        {
            if (compare_bn(t1, t2))
            {
                ++num;
            }
            else
            {
                t1 = t2;
                num = 1;
            }
            cout << t1.get_bn() << " has " << num << " records." << endl;
        }
    }
    else
    {
        cout << "No data!" << endl;
        return -1;
    }

    cout << "Bye!" << endl;
    return 0;
}